package com.zf.mall.common.response;

public enum ErrorEnum {
	/***************************** 请求成功 *****************************/
	C10000(10000, "成功"), C20000(20000, "请求失败!"),
	/*****************************************************************/
	
	C22000(22000,"该用户已存在,不能重复注册"),
	C22001(22001,"必填参数不能为空"),
	C22002(22002,"手机号不能为空"),
	C22003(22003,"该用户不存在"),
	C22004(22004,"数据错误,该用户存在多条记录"),
	C22005(22005,"该用户没有设置密码,无法使用密码登录"),
	C22006(22006,"用户名或密码错误,登录失败"),
	C22007(22007,"该资源暂时禁止访问!"),
	C22008(22008,"用户令牌不能为空"),
	C22009(22009,"登录状态已过期");
	
	

	private int code;
	private String message;
	private String desc;

	private ErrorEnum(int code, String message) {
		this.code = code;
		this.message = message;
	}

	private ErrorEnum(int code, String message, String desc) {
		this.code = code;
		this.message = message;
		this.desc = desc;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public String getDesc() {
		if (desc == null) {
			return message;
		}
		return desc;
	}

	public static ErrorEnum getError(int code) {
		for (ErrorEnum error : ErrorEnum.values()) {
			if (error.code == code) {
				return error;
			}
		}
		return null;
	}
}
